<me:UIWBBST x:Class="WPFExcelReport.TWBFREE"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL" 
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT" 
                    xmlns:WS="clr-namespace:WPFExcelReport;assembly=TWASTAMM" 
                    xmlns:BW="clr-namespace:WPFExcelReport;assembly=TWBBEW" 
                    xmlns:WFW="clr-namespace:WPFExcelReport;assembly=TICC_WFEVENTS"
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"  
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    Background="White"  
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIWBBST.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/> 
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:KM2YD x:Key="KM2YD"/>
        <ucd:M2YD x:Key="M2YD"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:PNumConverter  x:Key="pnum"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
        <ucd:NOTConverter x:Key="not"/>
        <ucd:TextTrimmingConverter x:Key="trim"/>
    </me:UIWBBST.Resources>
    <Grid IsEnabled="{Binding IsBusy,Converter={StaticResource not}}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="1*"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel  Grid.Row="0" Grid.Column="0" 
                         Visibility="{Binding IsCanNew,ElementName=TV,Converter={StaticResource bv}}">
                <WrapPanel >
                <WrapPanel >
                        
                        <Grid Margin="10,0,0,0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition> 
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" >库</TextBlock>
                        <ex:TXT72 MaxLength="2" PRE="  " Grid.Column="1"  FontSize="18" Foreground="Red"   Text="{Binding LO,ElementName=TV}" Width="30"/>
                        <ex:TXT72 MaxLength="2" PRE="  " Grid.Column="2"  FontSize="18" Foreground="Red"   Text="{Binding LB,ElementName=TV}" Width="30"/> 
                    </Grid> 
                </WrapPanel>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="FreeQtyCommand" Height="20" Margin="5,0,0,0" Width="Auto" Content="{Binding Source={Localization:Translate Word=自由数量}}" >
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="LockedQtyCommand" Height="20" Margin="5,0,0,0"  Width="Auto" Content="{Binding Source={Localization:Translate Word=锁定数量}}" >
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="AllQtyCommand" Height="20" Margin="5,0,0,0"  Width="Auto" Content="{Binding Source={Localization:Translate Word=全部数量}}" >
                    </Button>
                </Grid>  
                </WrapPanel>
                <WrapPanel>
                    <CheckBox Content="{Binding Source={Localization:Translate Word=全屏}}" IsChecked="{Binding IsZoneWBFull,ElementName=TV}" VerticalAlignment="Top"/> 
                    <Grid Margin="10,0,0,0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" >数量(米)</TextBlock>
                        <ex:NumericBox  Grid.Column="1" MaxLength="11" CharacterCasing="Upper" 
                                   Text="{Binding WBBISTKLG,Source={StaticResource ResourceKey=vwMaster},Converter={StaticResource d1000}}"
                                   Width="100"/>
                    </Grid> 
                
                    <Grid Margin="10,0,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button   Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24"  >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                            </Button.Background>
                        </Button>
                        <TextBlock Grid.Column="1" >留位</TextBlock>
                    </Grid> 
                </WrapPanel>
            </StackPanel>
            <DataGrid  Grid.Row="1" Grid.Column="0" 
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                       IsReadOnly="{Binding IsEdit,ElementName=TV,Converter={StaticResource not}}"
                   HeadersVisibility="Column"     
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster" 
                    RowDetailsVisibilityMode="Visible"  Margin="0,0,0,0">
                <DataGrid.Columns>
                    <DataGridCheckBoxColumn Width="40" Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type DataGridRow}}}">
                        <DataGridCheckBoxColumn.HeaderTemplate>
                            <DataTemplate>
                                <CheckBox x:Name="ckbSelectedAll" Checked="ckbSelectedAll_Click" Unchecked="ckbSelectedAll_Unchecked"></CheckBox>
                            </DataTemplate>
                            </DataGridCheckBoxColumn.HeaderTemplate>
                    </DataGridCheckBoxColumn>
                    <DataGridTextColumn  IsReadOnly="True"  Header="{Binding Source={Localization:Translate Word=布卷号}}" Binding="{Binding WBBSTKNR, Converter={StaticResource ResourceKey=pnum}}"/>
                    <DataGridTextColumn  Header="织边" Binding="{Binding WBBVAR}"/>
                    <DataGridTextColumn  Header="{Binding Source={Localization:Translate Word=数量(米)}}" Binding="{Binding WBBISTKLG,Converter={StaticResource ResourceKey=d1000}}"/>
                 </DataGrid.Columns>
            </DataGrid>
            <ex:TPage  Grid.Row="2" Visibility="{Binding IsPage,Converter={StaticResource bv}}"/>
            <WrapPanel Grid.Row="3">
                <ex:TSUMWB/>
                <ex:TPROCESS/>
            </WrapPanel> 
        </Grid>
    </Grid>
</me:UIWBBST>
